package com.mzj.saas.mservice.roles.repository;

import com.mzj.saas.mservice.roles.entity.UserRoleRef;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface UserRoleRefRepository extends PagingAndSortingRepository<UserRoleRef, Long>, JpaSpecificationExecutor<UserRoleRef>, JpaRepository<UserRoleRef, Long> {
    List<UserRoleRef> findByRoleId(Long roleId);

    UserRoleRef findByUserIdAndRoleId(String userId, Long roleId);

    @Transactional
    void deleteByUserIdAndRoleId(String userId, Long roleId);

    List<UserRoleRef> findByUserId(String userId);

    @Transactional
    void deleteByUserId(String userId);

    List<UserRoleRef> findByUserIdIn(List<String> userIds);

}
